/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package domain;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author amega
 */
@Entity
@Table(name = "visa")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Visa.findAll", query = "SELECT v FROM Visa v"),
    @NamedQuery(name = "Visa.findById", query = "SELECT v FROM Visa v WHERE v.id = :id"),
    @NamedQuery(name = "Visa.findByDateBegin", query = "SELECT v FROM Visa v WHERE v.dateBegin = :dateBegin"),
    @NamedQuery(name = "Visa.findByDateEnd", query = "SELECT v FROM Visa v WHERE v.dateEnd = :dateEnd"),
    @NamedQuery(name = "Visa.findByTypeVisa", query = "SELECT v FROM Visa v WHERE v.typeVisa = :typeVisa"),
    @NamedQuery(name = "Visa.findByDateOfIssue", query = "SELECT v FROM Visa v WHERE v.dateOfIssue = :dateOfIssue"),
    @NamedQuery(name = "Visa.findByPlaceOfIssue", query = "SELECT v FROM Visa v WHERE v.placeOfIssue = :placeOfIssue")})
public class Visa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateBegin")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateBegin;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateEnd")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateEnd;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "typeVisa")
    private String typeVisa;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateOfIssue")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfIssue;
    @Basic(optional = false)
    @NotNull
    @Column(name = "placeOfIssue")
    @Size(min = 1, max = 255)
    private String placeOfIssue;
    @JoinColumn(name = "idPassport", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Passport idPassport;
    @JoinColumn(name = "idUser", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Users idUser;

    public Visa() {
    }

    public Visa(Integer id) {
        this.id = id;
    }

    public Visa(Integer id, Date dateBegin, Date dateEnd, String typeVisa, Date dateOfIssue, String placeOfIssue) {
        this.id = id;
        this.dateBegin = dateBegin;
        this.dateEnd = dateEnd;
        this.typeVisa = typeVisa;
        this.dateOfIssue = dateOfIssue;
        this.placeOfIssue = placeOfIssue;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDateBegin() {
        return dateBegin;
    }

    public void setDateBegin(Date dateBegin) {
        this.dateBegin = dateBegin;
    }

    public Date getDateEnd() {
        return dateEnd;
    }

    public void setDateEnd(Date dateEnd) {
        this.dateEnd = dateEnd;
    }

    public String getTypeVisa() {
        return typeVisa;
    }

    public void setTypeVisa(String typeVisa) {
        this.typeVisa = typeVisa;
    }

    public Date getDateOfIssue() {
        return dateOfIssue;
    }

    public void setDateOfIssue(Date dateOfIssue) {
        this.dateOfIssue = dateOfIssue;
    }

    public String getPlaceOfIssue() {
        return placeOfIssue;
    }

    public void setPlaceOfIssue(String placeOfIssue) {
        this.placeOfIssue = placeOfIssue;
    }

    public Passport getIdPassport() {
        return idPassport;
    }

    public void setIdPassport(Passport idPassport) {
        this.idPassport = idPassport;
    }

    public Users getIdUser() {
        return idUser;
    }

    public void setIdUser(Users idUser) {
        this.idUser = idUser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Visa)) {
            return false;
        }
        Visa other = (Visa) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "domain.Visa[ id=" + id + " ]";
    }
    
}
